<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加店铺</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/admin/css/admin.css">
  <script src="/static/layui/layui.js"></script>
</head>
</body>
<div class="layui-container" style="margin-top: 30px;">
<form class="layui-form">
    <input type="hidden" name="id" value="{$row.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">店铺名称</label>
        <div class="layui-input-block">
          <input type="text" name="store_name" value="{$row.store_name}" required  lay-verify="required" placeholder="请输入店铺名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">店铺logo</label>
      <div class="layui-input-block">
        <input type="hidden" name="store_logo" value="{$row.store_logo}">
        <img src="{$row.store_logo}" class="layui-long-upimg upload">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">登录账号</label>
      <div class="layui-input-block">
        <input type="text" value="{$row.username}" disabled class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">登录密码</label>
      <div class="layui-input-block">
        <input type="password" name="password"  placeholder="请输入密码" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">再次输入密码</label>
      <div class="layui-input-block">
        <input type="password" name="password_confirm" placeholder="请再次输入密码" autocomplete="off" class="layui-input">
      </div>
   </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-block">
          <input type="text" name="company_name" value="{$row.company_name}" required  lay-verify="required" placeholder="请输入公司名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">营业执照</label>
        <div class="layui-input-block">
          <input type="hidden" name="business_license" value="{$row.business_license}">
          <img src="{$row.business_license}" class="layui-long-upimg upload">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">法人身份证号</label>
        <div class="layui-input-block">
          <input type="text" name="id_number" value="{$row.id_number}" required  lay-verify="required" placeholder="请输入法人身份证号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">法人身份证正反面</label>
        <div class="layui-input-block">
            <div class="layui-inline">
                <input type="hidden" name="id_card_front" value="{$row.id_card_front}">
                <img src="{$row.id_card_front}" class="layui-long-upimg upload">  
            </div>
            <div class="layui-inline">
                <input type="hidden" name="id_card_reverse" value="{$row.id_card_reverse}">
                <img src="{$row.id_card_reverse}" class="layui-long-upimg upload">  
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">法人姓名</label>
        <div class="layui-input-block">
          <input type="text" name="legal_person" value="{$row.legal_person}" required  lay-verify="required" placeholder="请输入法人姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">法人手机号</label>
        <div class="layui-input-block">
          <input type="text" name="legal_phone" required value="{$row.legal_phone}"  lay-verify="required" placeholder="请输入法人手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司地址</label>
        <div class="layui-input-block">
          <input type="text" name="company_address" value="{$row.company_address}" required  lay-verify="required" placeholder="请输入公司地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="1" {if condition='$row.status==1'} checked {/if} title="上线">
        <input type="radio" name="status" value="0" {if condition='$row.status==0'} checked {/if} title="下线">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formAdd">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
<script>
    //Demo
    layui.use(['form','upload'], function(){
      var $ = layui.jquery,form = layui.form,upload = layui.upload;

      upload.render({
          elem: ".upload",
          field: "image",
          url: "/admin/upload",
          done: function(res){
            let item = this.item;
              if(res.code==1){
                $(item).attr('src',res.src)
                $(item).siblings('input[type=hidden]').val(res.src);
              }
          }
      });
      form.on('submit(formAdd)',function(data){
          $.post('/admin/store/update',data.field,function(res){
                if(res.code ==1 ){
                  let index =  parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.$.pjax.reload('#main',{fragment: '#main'});
                }
                return layer.msg(res.msg,{icon:2});
          });
          return false;
      });
     
    });
    </script>
</body>
</html>